Editorial review: Document WebXR visibilitymaskchange event#43975
Editorial review: Document WebXR visibilitymaskchange event#43975chrisdavidmills wants to merge 2 commits intomdn:mainfrom
Conversation
|
|
||
| ```js | ||
| xrSession.addEventListener("visibilitymaskchange", (e) => { | ||
| if (userSessionEnded) { |
There was a problem hiding this comment.
NIT: This is a little confusing, I thought it was tracking some variable that the session had already ended at first glance/read through. maybe userRequestsSessionEnd and clear it in the block as well?
There was a problem hiding this comment.
That's a fair comment. I've updated the variable name throughout to userRequestsSessionEnd in my next commit.
|
|
||
| {{APIRef("WebXR Device API")}}{{SecureContext_Header}} | ||
|
|
||
| The read-only **`vertices`** property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface is an array of coordinates representing the vertices required to draw the entire scene displayed in the {{domxref("XRView")}}. If this array is empty, the whole region of the `XRView` will be drawn. |
There was a problem hiding this comment.
Maybe also reference here that it's intended to be referenced into by the indices property.
There was a problem hiding this comment.
Sure, makes sense. I've added the following in a new paragraph:
The {{domxref("XRVisibilityMaskChangeEvent.indices", "indices")}} array specifies the indices of the
verticesarray that should be drawn to display the currently visible part of the scene displayed in theXRView.
There was a problem hiding this comment.
More detail required than that to allow readers to understand what is going on
If these are floats, then they are numbers, not "points" so my guess in https://github.com/mdn/content/pull/43975/changes#r3215903956 is completely wrong. But the comment is valid - a reader should be able to work out how this works.
| A number. | ||
|
|
||
| ## Examples | ||
|
|
There was a problem hiding this comment.
As per the template, though it feels a bit pointless
| ### Basic usage | |
|
|
||
| {{APIRef("WebXR Device API")}}{{SecureContext_Header}} | ||
|
|
||
| The read-only **`index`** property of the {{domxref("XRView")}} interface indicates the index of the current `XRView` in the {{domxref("XRViewerPose.views")}} array. |
There was a problem hiding this comment.
For all these it is this form
| The read-only **`index`** property of the {{domxref("XRView")}} interface indicates the index of the current `XRView` in the {{domxref("XRViewerPose.views")}} array. | |
| The **`index`** read-only property of the {{domxref("XRView")}} interface indicates the index of the current `XRView` in the {{domxref("XRViewerPose.views")}} array. |
|
|
||
| {{APIRef("WebXR Device API")}}{{SecureContext_Header}} | ||
|
|
||
| The read-only **`eye`** property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface indicates the eye the mask applies to. |
There was a problem hiding this comment.
For all
| The read-only **`eye`** property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface indicates the eye the mask applies to. | |
| The **`eye`** read-only property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface indicates the eye the mask applies to. |
| An emumerated value indicating which eye the mask applies to, which can be one of: | ||
|
|
||
| - `left` | ||
| - : The {{domxref("XRView")}} represents the point-of-view of the viewer's left eye. | ||
| - `right` | ||
| - : The view represents the viewer's right eye. | ||
| - `none` | ||
| - : The `XRView` describes a monoscopic view, or the view otherwise doesn't represent a particular eye's point-of-view. |
There was a problem hiding this comment.
There is a bunch of stuff that confuses me here. How does {{domxref("XRView")}} map to eye? Mentioning a view below feels like he wrong place - if there is a relationship then push it into the intro above or in the intro sentence here.
This bit should look like
| An emumerated value indicating which eye the mask applies to, which can be one of: | |
| - `left` | |
| - : The {{domxref("XRView")}} represents the point-of-view of the viewer's left eye. | |
| - `right` | |
| - : The view represents the viewer's right eye. | |
| - `none` | |
| - : The `XRView` describes a monoscopic view, or the view otherwise doesn't represent a particular eye's point-of-view. | |
| An emumerated value indicating which eye the mask applies to from the viewer's perspective. | |
| This can be one of: | |
| - `left` | |
| - : The viewer's left eye. | |
| - `right` | |
| - : The viewer's right eye. | |
| - `none` | |
| - : A monoscopic view, or the view otherwise doesn't represent a particular eye's point-of-view. |
| - : The `XRView` describes a monoscopic view, or the view otherwise doesn't represent a particular eye's point-of-view. | ||
|
|
||
| ## Examples | ||
|
|
There was a problem hiding this comment.
| ### Basic usage | |
|
|
||
| {{APIRef("WebXR Device API")}}{{SecureContext_Header}} | ||
|
|
||
| The read-only **`index`** property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface indicates the index of the current {{domxref("XRView")}} in the {{domxref("XRViewerPose.views")}} array. |
There was a problem hiding this comment.
| The read-only **`index`** property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface indicates the index of the current {{domxref("XRView")}} in the {{domxref("XRViewerPose.views")}} array. | |
| The **`index`** read-only property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface indicates the index of the current {{domxref("XRView")}} in the {{domxref("XRViewerPose.views")}} array. |
There was a problem hiding this comment.
A sentence on how many views there might be in that array, and why the index matters might be useful.
It's always a balance how much to say in reference - ie. how much context you should need to provide. I don't feel like I have enough to do anything useful with this page.
|
|
||
| {{APIRef("WebXR Device API")}}{{SecureContext_Header}} | ||
|
|
||
| The read-only **`indices`** property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface is an array of indices specifying the vertices in the {{domxref("XRVisibilityMaskChangeEvent.vertices", "vertices")}} array that should be drawn to display the currently visible part of the scene displayed in the `XRView`. If this array is empty, the whole region of the `XRView` will be drawn. |
There was a problem hiding this comment.
| The read-only **`indices`** property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface is an array of indices specifying the vertices in the {{domxref("XRVisibilityMaskChangeEvent.vertices", "vertices")}} array that should be drawn to display the currently visible part of the scene displayed in the `XRView`. If this array is empty, the whole region of the `XRView` will be drawn. | |
| The **`indices`** read-only property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface is an array of indices specifying the vertices in the {{domxref("XRVisibilityMaskChangeEvent.vertices", "vertices")}} array that should be drawn to display the currently visible part of the scene displayed in the `XRView`. If this array is empty, the whole region of the `XRView` will be drawn. |
|
|
||
| {{APIRef("WebXR Device API")}}{{SecureContext_Header}} | ||
|
|
||
| The read-only **`indices`** property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface is an array of indices specifying the vertices in the {{domxref("XRVisibilityMaskChangeEvent.vertices", "vertices")}} array that should be drawn to display the currently visible part of the scene displayed in the `XRView`. If this array is empty, the whole region of the `XRView` will be drawn. |
There was a problem hiding this comment.
This isn't enough information to understand how indices and vertices work.
A vertix is a co-ordinate. You can define a polygonal region using more than three vertices (some care is required in definitions because if you assume vertices are somehow ordered, it is possible to cross over your path and define odd geometries.
Anyway, from this I'd guess that the verticies defines an array of points. This might have many more points than in the mask, so you have a indicies array that specifies the numbers in the vertices array that define the actual mask. That might be completely wrong, but whatever the truth is it needs to be said somewhere.
Other things I'd like to know - is the masked area the inner polygon defined by your vertices or the external area? Does the set of vertices defined here change with the event - I presume so?
|
|
||
| {{APIRef("WebXR Device API")}}{{SecureContext_Header}} | ||
|
|
||
| The read-only **`session`** property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface indicates the {{domxref("XRSession")}} to which the event belongs. |
There was a problem hiding this comment.
| The read-only **`session`** property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface indicates the {{domxref("XRSession")}} to which the event belongs. | |
| The **`session`** read-only property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface indicates the {{domxref("XRSession")}} to which the event belongs. |
| An {{domxref("XRSession")}} object indicating which WebXR session the event belongs to. | ||
|
|
||
| ## Examples | ||
|
|
There was a problem hiding this comment.
Level three heading is in template. This is kind of the "default" but if you can find something more meaningful that is good.
| ### Basic usage |
| {{APIRef("WebXR Device API")}}{{SecureContext_Header}} | ||
|
|
||
| The read-only **`session`** property of the {{domxref("XRVisibilityMaskChangeEvent")}} interface indicates the {{domxref("XRSession")}} to which the event belongs. | ||
|
|
There was a problem hiding this comment.
What's a session? Is there a sentence we could add to explain the relevance?
| The WebXR Device API's | ||
| **`XRVisibilityMaskChangeEvent()`** constructor creates and returns a new | ||
| {{domxref("XRVisibilityMaskChangeEvent")}} object. |
There was a problem hiding this comment.
The https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Page_structures/Page_types/API_constructor_subpage_template template isn't very clear yet, but a more "standard format" would be to
- not have odd line breaks
- Do something like
| The WebXR Device API's | |
| **`XRVisibilityMaskChangeEvent()`** constructor creates and returns a new | |
| {{domxref("XRVisibilityMaskChangeEvent")}} object. | |
| The **`XRVisibilityMaskChangeEvent()`** constructor creates and returns a new {{domxref("XRVisibilityMaskChangeEvent")}} object. |
|
|
||
| {{APIRef("WebXR Device API")}}{{SecureContext_Header}} | ||
|
|
||
| The **`XRVisibilityMaskChangeEvent`** of the [WebXR Device API](/en-US/docs/Web/API/WebXR_Device_API) describes the portion of an {{domxref("XRView")}} visible to the user (that is, the portion not hidden by the mask) after the view has changed. This enables performance improvements by allowing the browser to draw only the visible part of the updated view. |
There was a problem hiding this comment.
This enables performance improvements by allowing the browser to draw only the visible part of the updated view.
Er, users get events - browsers generate them. So I can see that a browser can enable performance improvements, but it isn't clear what the user is supposed to do with this event and why it is relevant.
|
|
||
| {{APIRef("WebXR Device API")}}{{SeeCompatTable}}{{SecureContext_Header}} | ||
|
|
||
| The **`visibilitymaskchange`** event is sent to an {{domxref("XRSession")}} when the portion of an {{domxref("XRView")}} visible to the user changes — that is, the portion not hidden by the mask. This enables performance improvements by allowing the browser to draw only the visible part of the updated view. The required information to draw the update is contained in the {{domxref("XRVisibilityMaskChangeEvent")}} event object. |
There was a problem hiding this comment.
See https://github.com/mdn/content/pull/43975/changes#r3215941539 - it isn't clear to me how this works, since events are handled by user code, but it talks about browser behaviour.
The required information to draw the update is contained in the {{domxref("XRVisibilityMaskChangeEvent")}} event object.
As I understand it the event is-a XRVisibilityMaskChangeEvent - this is an odd way to say that. Am I missing something?
| - : The {{domxref("XRSession")}} to which the event refers. | ||
| - {{domxref("XRVisibilityMaskChangeEvent.vertices", "vertices")}} {{ReadOnlyInline}} | ||
| - : An array of coordinates representing the vertices required to draw the entire scene displayed in the `XRView`. If this array is empty, the whole region of the `XRView` will be drawn. | ||
|
|
There was a problem hiding this comment.
And what also not in the template, but is always appreciated is a section "Events" that lists the actual events fired from this type.
I'm doing something similar in https://github.com/mdn/content/pull/44047/changes#diff-3b2cb04c1d5d238054f6807ab130a07a1f1bb8ca392b0a092c0073354f523f94
|
|
||
| {{InheritanceDiagram("XRVisibilityMaskChangeEvent")}} | ||
|
|
||
| ## Event properties |
There was a problem hiding this comment.
I think I need to update the template. An event is just an interface. This should be instance properties.
Description
Chrome 144 adds support for the
visibilitymaskchangeevent/XRVisibilityMaskChangeevent object; see https://chromestatus.com/feature/5073760055066624.This PR adds documentation for:
XRVisibilityMaskChangeevent object and all its members.visibilitymaskchangeeventXRView.indexproperty.Motivation
Additional details
Related issues and pull requests